<template>
  <div class="progressbar">
    <progress :percent="percent" activeColor="#EA5A49"></progress>
    <p>{{year}}已经过去了{{days}}天，{{percent}}%</p>
  </div>
</template>
<script>
export default {
  /* eslint-disable */
  methods: {
    getDayOfYear: () => {
      let year = new Date().getFullYear()
      let isLeap = (year % 4 === 0) && (year % 100 === 0) || (year % 400 === 0)
      return isLeap ? 366 : 365
    }
  },
  computed: {
    year () {
      return new Date().getFullYear()
    },
    days () {
      let start = new Date()
      start.setMonth(0)
      start.setDate(1)
      let offset = new Date().getTime() - start.getTime()
      return parseInt(offset / 1000 / 60 / 60 / 24) + 1
    },
    percent () {
      return (this.days * 100 / this.getDayOfYear()).toFixed(1)
    }
  }
}
</script>
<style lang="scss">
.progressbar {
  width: 100%;
  margin: 30rpx 0 60rpx;
  progress{
    margin-bottom: 20rpx;
  }
}
</style>

